import createjs from "createjs-ts"
import cjs=createjs
import DoubleFingerScaleHelper from "./helper/DoubleFingerScaleHelper"
import { GameConfig } from "./Const"
import BitmapContainer from "./BitmapContainer"
export default class ExportRoot extends cjs.Container {
    private gride:cjs.Shape
    /*private p0:cjs.Shape
    private p1:cjs.Shape
    private p2:cjs.Shape*/
    private pic:BitmapContainer
    constructor() {
        super()
        this.gride = new cjs.Shape();
        this.gride.graphics.beginStroke("#000000")
        this.gride.graphics.setStrokeStyle(1)
        for(let i=0;i<15;i++) {
            this.gride.graphics.moveTo(i*50,0).lineTo(i*50,2000);

        }
        this.gride.graphics.endStroke();
        //this.addChild(this.gride);
        //
        this.pic = new BitmapContainer();
        this.pic.setTransform(0,0,0.5,0.5)
        this.addChild(this.pic);
        //
        const p0 = new cjs.Shape();
        p0.graphics.beginStroke("#000000").drawCircle(0,0,15);
        //this.p0.setTransform(0,450);
        const p1 = new cjs.Shape();
        p1.graphics.beginStroke("#000000").drawCircle(0,0,15);
        //this.p1.setTransform(300,150);
        const p2 = new cjs.Shape();
        p2.graphics.beginStroke("#000000").drawCircle(0,0,15);
        //this.p2.setTransform(550,450);
        this.addChild(p2,p1,p0);
        //
        this.on('added',()=>{
            console.log(GameConfig)
            this.stage.on('stagemousedown',((e:cjs.MouseEvent)=>{
                this.globalToLocal(e.stageX,e.stageY,p0)
                const reg=this.pic.globalToLocal(e.stageX,e.stageY)
                this.pic.setRegPoint(reg.x,reg.y)
            }).bind(this))
            /*new DoubleFingerScaleHelper(this.pic,
                devicePixelRatio,
                Number.MAX_VALUE,
                Number.MIN_VALUE,
                (tp0:cjs.Point,tp1:cjs.Point,tp2:cjs.Point)=>{
                    const reg=this.pic.globalToLocal(tp2.x,tp2.y)
                    this.pic.setRegPoint(reg.x,reg.y)
                    this.pic.setDoubleFiger(this.pic.globalToLocal(tp0.x,tp0.y),this.pic.globalToLocal(tp1.x,tp1.y))
                    this.globalToLocal(tp0.x,tp0.y,p0)
                    this.globalToLocal(tp1.x,tp1.y,p1)
                    this.globalToLocal(tp2.x,tp2.y,p2)
                },(tp0:cjs.Point,tp1:cjs.Point,tp2:cjs.Point)=>{
                    const reg=this.pic.globalToLocal(tp2.x,tp2.y)
                    this.pic.setRegPoint(reg.x,reg.y)
                    this.pic.setDoubleFiger(this.pic.globalToLocal(tp0.x,tp0.y),this.pic.globalToLocal(tp1.x,tp1.y))
                    this.globalToLocal(tp0.x,tp0.y,p0)
                    this.globalToLocal(tp1.x,tp1.y,p1)
                    this.globalToLocal(tp2.x,tp2.y,p2)
                })*/
        },this,true)
    }
}